<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AIfES 2: aimath_q31.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="AIfES_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AIfES 2
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('aimath__q31_8h.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">aimath_q31.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Definition of the Q31 (aiq31) data-type.  
<a href="#details">More...</a></p>

<p><a href="aimath__q31_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structaimath__q31__params.html">aimath_q31_params</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parameters used for the quantized <a class="el" href="aimath__q31_8h.html">Q31 </a> values, used as property of a tensor.  <a href="structaimath__q31__params.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structaiscalar__q31.html">aiscalar_q31</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Single quantized <a class="el" href="aimath__q31_8h.html">Q31 </a> value/scalar.  <a href="structaiscalar__q31.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a3f46d45ebbddd88260888a25e5279924"><td class="memItemLeft" align="right" valign="top"><a id="a3f46d45ebbddd88260888a25e5279924"></a>
typedef struct <a class="el" href="structaimath__q31__params.html">aimath_q31_params</a>&#160;</td><td class="memItemRight" valign="bottom"><b>aimath_q31_params_t</b></td></tr>
<tr class="separator:a3f46d45ebbddd88260888a25e5279924"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a39892302b6eb71fcbe5e3af4f0bbc6"><td class="memItemLeft" align="right" valign="top"><a id="a1a39892302b6eb71fcbe5e3af4f0bbc6"></a>
typedef struct <a class="el" href="structaiscalar__q31.html">aiscalar_q31</a>&#160;</td><td class="memItemRight" valign="bottom"><b>aiscalar_q31_t</b></td></tr>
<tr class="separator:a1a39892302b6eb71fcbe5e3af4f0bbc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a541e04ea103af9dbbd9ec41934dbf2af"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q31_8h.html#a541e04ea103af9dbbd9ec41934dbf2af">aimath_q31_print_aitensor</a> (const <a class="el" href="structaitensor.html">aitensor_t</a> *tensor)</td></tr>
<tr class="memdesc:a541e04ea103af9dbbd9ec41934dbf2af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Printing a Q31 tensor to console.  <a href="aimath__q31_8h.html#a541e04ea103af9dbbd9ec41934dbf2af">More...</a><br /></td></tr>
<tr class="separator:a541e04ea103af9dbbd9ec41934dbf2af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7359acc9b475f46d48ce80ef7c74114f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q31_8h.html#a7359acc9b475f46d48ce80ef7c74114f">aimath_q31_print_aiscalar</a> (const void *scalar)</td></tr>
<tr class="memdesc:a7359acc9b475f46d48ce80ef7c74114f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Printing a Q31 scalar to console.  <a href="aimath__q31_8h.html#a7359acc9b475f46d48ce80ef7c74114f">More...</a><br /></td></tr>
<tr class="separator:a7359acc9b475f46d48ce80ef7c74114f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e5faeb8c077d061d6e8d48543b947c5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q31_8h.html#a3e5faeb8c077d061d6e8d48543b947c5">aimath_q31_calc_q_params_from_f32</a> (float min_value, float max_value, <a class="el" href="structaimath__q31__params.html">aimath_q31_params_t</a> *q_params)</td></tr>
<tr class="memdesc:a3e5faeb8c077d061d6e8d48543b947c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calculates the <a class="el" href="structaimath__q31__params.html" title="Parameters used for the quantized Q31  values, used as property of a tensor.">aimath_q31_params</a> parameters.  <a href="aimath__q31_8h.html#a3e5faeb8c077d061d6e8d48543b947c5">More...</a><br /></td></tr>
<tr class="separator:a3e5faeb8c077d061d6e8d48543b947c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac204ae3be0fdc2b0ac57369254c58f1a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q31_8h.html#ac204ae3be0fdc2b0ac57369254c58f1a">aimath_q31_quantize_tensor_from_f32</a> (const <a class="el" href="structaitensor.html">aitensor_t</a> *tensor_f32, <a class="el" href="structaitensor.html">aitensor_t</a> *tensor_q31)</td></tr>
<tr class="memdesc:ac204ae3be0fdc2b0ac57369254c58f1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Converts a float f32 tensor into a quantized q31 tensor.  <a href="aimath__q31_8h.html#ac204ae3be0fdc2b0ac57369254c58f1a">More...</a><br /></td></tr>
<tr class="separator:ac204ae3be0fdc2b0ac57369254c58f1a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ac5314582da98b2cdbe4b445ea25f0b77"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structaimath__dtype.html">aimath_dtype_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">aiq31</a></td></tr>
<tr class="memdesc:ac5314582da98b2cdbe4b445ea25f0b77"><td class="mdescLeft">&#160;</td><td class="mdescRight">The Q31 data-type indicator.  <a href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">More...</a><br /></td></tr>
<tr class="separator:ac5314582da98b2cdbe4b445ea25f0b77"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Definition of the Q31 (aiq31) data-type. </p>
<dl class="section version"><dt>Version</dt><dd>2.2.0 </dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2020-2023 Fraunhofer Institute for Microelectronic Circuits and Systems. All rights reserved.<br  />
<br  />
 AIfES is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br  />
<br  />
 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.<br  />
<br  />
 You should have received a copy of the GNU Affero General Public License along with this program. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.</dd></dl>
<p>The Q31 (aiq31) data-type stores data as quantized 32 bit integer values. In addition a scaling factor (shift) and a zero point (zero_point) is needed to fully define the value.</p>
<p>The Q31 quantization is a asymmetric 32 bit integer quantization that allows integer-only calculations on real values. A real value \( r \) is represented by an integer value \( q \), the scaling factor / shift \( s \) and the zero point \( z \) according to the following formula: </p><p class="formulaDsp">
\[ r = 2^{-s} * (q - z) \]
</p>
<p>To get the quantized value \( q \) out of a real value you have to calculate </p><p class="formulaDsp">
\[ q = round(\frac{x}{2^{-s}} + z) \]
</p>
<p><b>Example: Create a Q31 tensor</b><br  />
The tensor </p><p class="formulaDsp">
\[ \left( \begin{array}{rrr} 0 &amp; 1 &amp; 2 \\ 3 &amp; 4 &amp; 5 \end{array}\right) \]
</p>
<p> can be created with In C: </p><div class="fragment"><div class="line">int32_t example_data[] = {0, 1, 2</div>
<div class="line">                          3, 4, 5};</div>
<div class="line">uint16_t example_shape[] = {2, 3};</div>
<div class="line"><a class="code" href="structaimath__q31__params.html">aimath_q31_params_t</a> example_q_params = { .<a class="code" href="structaimath__q31__params.html#a8f20d77488fe485aaf9ea8e9c5d7d35e">shift</a> = 0, .zero_point = 0 };</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> example_tensor = {</div>
<div class="line">    .<a class="code" href="structaitensor.html#abf7a461af7296a09d5246ca13591b988">dtype</a> = <a class="code" href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">aiq31</a>,</div>
<div class="line">    .dim = 2,</div>
<div class="line">    .shape = example_shape,</div>
<div class="line">    .tensor_params = example_q_params,</div>
<div class="line">    .data = example_data</div>
<div class="line">};</div>
<div class="ttc" id="aaimath__q31_8h_html_ac5314582da98b2cdbe4b445ea25f0b77"><div class="ttname"><a href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">aiq31</a></div><div class="ttdeci">const aimath_dtype_t * aiq31</div><div class="ttdoc">The Q31 data-type indicator.</div></div>
<div class="ttc" id="astructaimath__q31__params_html"><div class="ttname"><a href="structaimath__q31__params.html">aimath_q31_params</a></div><div class="ttdoc">Parameters used for the quantized Q31  values, used as property of a tensor.</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:149</div></div>
<div class="ttc" id="astructaimath__q31__params_html_a8f20d77488fe485aaf9ea8e9c5d7d35e"><div class="ttname"><a href="structaimath__q31__params.html#a8f20d77488fe485aaf9ea8e9c5d7d35e">aimath_q31_params::shift</a></div><div class="ttdeci">uint16_t shift</div><div class="ttdoc">The scaling factor  of the quantization (The total scale is calculated with )</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:150</div></div>
<div class="ttc" id="astructaitensor_html"><div class="ttname"><a href="structaitensor.html">aitensor</a></div><div class="ttdoc">A tensor in AIfES.</div><div class="ttdef"><b>Definition:</b> aifes_math.h:89</div></div>
<div class="ttc" id="astructaitensor_html_abf7a461af7296a09d5246ca13591b988"><div class="ttname"><a href="structaitensor.html#abf7a461af7296a09d5246ca13591b988">aitensor::dtype</a></div><div class="ttdeci">const aimath_dtype_t * dtype</div><div class="ttdoc">The datatype of the tensor, e.g.</div><div class="ttdef"><b>Definition:</b> aifes_math.h:90</div></div>
</div><!-- fragment --><p> In C, C++ and on Arduino: </p><div class="fragment"><div class="line">int32_t example_data[] = {0, 1, 2</div>
<div class="line">                          3, 4, 5};</div>
<div class="line">uint16_t example_shape[] = {2, 3};</div>
<div class="line"><a class="code" href="structaimath__q31__params.html">aimath_q31_params_t</a> example_q_params = { .<a class="code" href="structaimath__q31__params.html#a8f20d77488fe485aaf9ea8e9c5d7d35e">shift</a> = 0, .zero_point = 0 };</div>
<div class="line"><a class="code" href="structaitensor.html">aitensor_t</a> example_tensor = AITENSOR_2D_Q31(example_shape, &amp;example_q_params, example_data);</div>
</div><!-- fragment --><p><b>Example: Create a Q31 scalar</b><br  />
Either create it with the helper macro </p><div class="fragment"><div class="line"><a class="code" href="structaiscalar__q31.html">aiscalar_q31_t</a> scalar = AISCALAR_Q31(42.0f, 16, 0);</div>
<div class="ttc" id="astructaiscalar__q31_html"><div class="ttname"><a href="structaiscalar__q31.html">aiscalar_q31</a></div><div class="ttdoc">Single quantized Q31  value/scalar.</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:156</div></div>
</div><!-- fragment --><p> or manual with </p><div class="fragment"><div class="line"><a class="code" href="structaiscalar__q31.html">aiscalar_q31_t</a> scalar = { .<a class="code" href="structaiscalar__q31.html#a01571c420f280137c16d319178731da5">value</a> = 2552512, .shift = 16, .zero_point = 0};</div>
<div class="ttc" id="astructaiscalar__q31_html_a01571c420f280137c16d319178731da5"><div class="ttname"><a href="structaiscalar__q31.html#a01571c420f280137c16d319178731da5">aiscalar_q31::value</a></div><div class="ttdeci">int32_t value</div><div class="ttdoc">Quantized value .</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:157</div></div>
</div><!-- fragment --><p><b>Example: Print a Q31 tensor to the console</b> </p><div class="fragment"><div class="line"><a class="code" href="aimath__basic_8h.html#ab10c8d06990943806f0be8fcc6af03fc">print_aitensor</a>(&amp;example_tensor);</div>
<div class="ttc" id="aaimath__basic_8h_html_ab10c8d06990943806f0be8fcc6af03fc"><div class="ttname"><a href="aimath__basic_8h.html#ab10c8d06990943806f0be8fcc6af03fc">print_aitensor</a></div><div class="ttdeci">void print_aitensor(const aitensor_t *tensor)</div><div class="ttdoc">Printing a tensor to console.</div></div>
</div><!-- fragment --><p><b>Example: Print a Q31 scalar to the console</b> </p><div class="fragment"><div class="line"><a class="code" href="aimath__basic_8h.html#aaa9ca757028820849ef3dde13cc46565">print_aiscalar</a>(&amp;scalar, <a class="code" href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">aiq31</a>);</div>
<div class="ttc" id="aaimath__basic_8h_html_aaa9ca757028820849ef3dde13cc46565"><div class="ttname"><a href="aimath__basic_8h.html#aaa9ca757028820849ef3dde13cc46565">print_aiscalar</a></div><div class="ttdeci">void print_aiscalar(const void *scalar, const aimath_dtype_t *dtype)</div><div class="ttdoc">Printing a scalar to console.</div></div>
</div><!-- fragment --> </div><h2 class="groupheader">Function Documentation</h2>
<a id="a3e5faeb8c077d061d6e8d48543b947c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3e5faeb8c077d061d6e8d48543b947c5">&#9670;&nbsp;</a></span>aimath_q31_calc_q_params_from_f32()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aimath_q31_calc_q_params_from_f32 </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>min_value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>max_value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structaimath__q31__params.html">aimath_q31_params_t</a> *&#160;</td>
          <td class="paramname"><em>q_params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Calculates the <a class="el" href="structaimath__q31__params.html" title="Parameters used for the quantized Q31  values, used as property of a tensor.">aimath_q31_params</a> parameters. </p>
<p>Given a minimum and a maximum value, this function calculates the scaling shift and zero shift parameters for <a class="el" href="structaimath__q31__params.html" title="Parameters used for the quantized Q31  values, used as property of a tensor.">aimath_q31_params</a></p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">min_value</td><td>Minimum value of a given range </td></tr>
    <tr><td class="paramname">max_value</td><td>Maximum value of a given range </td></tr>
    <tr><td class="paramname">*q_params</td><td>Pointer to write the results <a class="el" href="structaimath__q31__params.html#a43cdb7ca657bf35ee727cdbae02fced9" title="The zero point  of the quantization.">aimath_q31_params::zero_point</a> and <a class="el" href="structaimath__q31__params.html#a8f20d77488fe485aaf9ea8e9c5d7d35e" title="The scaling factor  of the quantization (The total scale is calculated with )">aimath_q31_params::shift</a> into </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a7359acc9b475f46d48ce80ef7c74114f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7359acc9b475f46d48ce80ef7c74114f">&#9670;&nbsp;</a></span>aimath_q31_print_aiscalar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aimath_q31_print_aiscalar </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>scalar</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Printing a Q31 scalar to console. </p>
<p>For users the function </p><div class="fragment"><div class="line"><a class="code" href="aimath__basic_8h.html#aaa9ca757028820849ef3dde13cc46565">print_aiscalar</a>(&amp;scalar, <a class="code" href="aimath__q31_8h.html#ac5314582da98b2cdbe4b445ea25f0b77">aiq31</a>);</div>
</div><!-- fragment --><p> is prefered.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*scalar</td><td>The scalar (type: aiscalar_q31_t) to print. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a541e04ea103af9dbbd9ec41934dbf2af"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a541e04ea103af9dbbd9ec41934dbf2af">&#9670;&nbsp;</a></span>aimath_q31_print_aitensor()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aimath_q31_print_aitensor </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>tensor</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Printing a Q31 tensor to console. </p>
<p>For users the function </p><div class="fragment"><div class="line"><a class="code" href="aimath__basic_8h.html#ab10c8d06990943806f0be8fcc6af03fc">print_aitensor</a>(&amp;tensor);</div>
</div><!-- fragment --><p> is prefered.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*tensor</td><td>The tensor to print. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ac204ae3be0fdc2b0ac57369254c58f1a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac204ae3be0fdc2b0ac57369254c58f1a">&#9670;&nbsp;</a></span>aimath_q31_quantize_tensor_from_f32()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aimath_q31_quantize_tensor_from_f32 </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>tensor_f32</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structaitensor.html">aitensor_t</a> *&#160;</td>
          <td class="paramname"><em>tensor_q31</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Converts a float f32 tensor into a quantized q31 tensor. </p>
<p>Converts a float f32 tensor into a quantized q31 tensor by applying the aimath_q31_params_t given in the quantized q31 tensor</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">*tensor_f32</td><td>Float f32 tensor to convert from </td></tr>
    <tr><td class="paramname">*tensor_q31</td><td>quantized q31 tensor to convert to, included <a class="el" href="structaimath__q31__params.html" title="Parameters used for the quantized Q31  values, used as property of a tensor.">aimath_q31_params</a> must be set beforehand </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="ac5314582da98b2cdbe4b445ea25f0b77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac5314582da98b2cdbe4b445ea25f0b77">&#9670;&nbsp;</a></span>aiq31</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const <a class="el" href="structaimath__dtype.html">aimath_dtype_t</a>* aiq31</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">extern</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>The Q31 data-type indicator. </p>
<p>Use this variable to configure some element with the <a class="el" href="aimath__q31_8h.html">Q31 </a> data-type, </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_1e5d3661ed79af157d57e64a38265d09.html">basic</a></li><li class="navelem"><a class="el" href="dir_90008ee2b0f86999412b56217da88d54.html">base</a></li><li class="navelem"><a class="el" href="dir_4fb15a30b37b64fdad6823e3082f73a4.html">aimath</a></li><li class="navelem"><a class="el" href="aimath__q31_8h.html">aimath_q31.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
